<!DOCTYPE html>
<html class="x-admin-sm">

<head>
	<meta charset="UTF-8">
	<title>电子学会比赛管理系统</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/>
	<link rel="stylesheet" href="./css/font.css">
	<link rel="stylesheet" href="./css/common.css">
	<link rel="stylesheet" href="./css/xadmin.css">
	<script type="text/javascript" src="./js/abkj/auth/api/adminzoneview.js"></script>
	<script type="text/javascript" src="./js/abkj/auth/api/userinfoview.js"></script>
	<script type="text/javascript" src="./js/abkj/ext/matchExt.js"></script>
	<script type="text/javascript" src="./js/abkj/auth/api/account.js"></script>
	<script type="text/javascript" src="./js/abkj/match/api/grade.js"></script>
	<script type="text/javascript" src="./js/abkj/match/api/zone.js"></script>
	<script type="text/javascript" src="./js/abkj/match/api/tmatch.js"/></script>


	<script type="text/javascript" src="./js/abkj/fun_tool.js"></script>
	<script type="text/javascript" src="./js/abkj/slAjax.js"></script>
	<script src="./lib/layui/layui.js" charset="utf-8"></script>
	<script type="text/javascript" src="./js/xadmin.js"></script>
</head>

<body>
<div id="content">
	<div class="x-nav">
	<span class="layui-breadcrumb">
			<a href="">首页</a>
			<a><cite>系统管理</cite></a>
			<a><cite>裁判管理</cite></a>
	</span>
		<a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" onclick="location.reload()" title="刷新">
			<i class="layui-icon layui-icon-refresh" style="line-height:30px"></i>
		</a>
	</div>
	<div class="layui-fluid">
		<div class="layui-row layui-col-space15">
			<div class="layui-col-md12">
				<div class="layui-card">
					<div class="layui-card-body ">
						<div class="layui-form layui-col-space5 flex" style="display: flex;">
							<div class="layui-input-inline layui-show-xs-block flex">
								<div class="mr5">审核状态</div>
								<select name="status" id="zhuangtai">
									<option value="">全部</option>
									<option value="0">待审核</option>
									<option value="1">通过</option>
									<option value="2">不通过</option>
								</select>
							</div>
							<!-- <div class="layui-input-inline layui-show-xs-block flex" style="display:none">
								<div class="mr5">赛区</div>
								<select name="division" id="saiqu">
										<option value="">全部</option>
									<option v-for="zone in zoneList" :value="zone.id">{{zone.zoneName}}</option>
								</select>
							</div> -->
							<div class="layui-input-inline layui-show-xs-block flex">
								<div class="mr5" style="width: 40px;" >账号</div>
								<input type="text" name="number" placeholder="账号" autocomplete="off" class="layui-input" id="zhanghao"></div>
							<div class="layui-input-inline layui-show-xs-block">
								<button class="layui-btn" lay-submit="" lay-filter="sreach" onclick="search1()">
									<i class="layui-icon">&#xe615;</i></button>
							</div>
						</div>
					</div>
					<div class="layui-card-header">
						<!--<button class="layui-btn layui-btn-danger" onclick="delAll()">-->
						<!--<i class="layui-icon"></i>批量删除-->
						<!--</button>-->
						<!--<button class="layui-btn" onclick="xadmin.open('添加用户','./order-add.html',800,600)">-->
						<!--<i class="layui-icon"></i>添加-->
						<!--</button>-->
					</div>
					<div class="layui-card-body ">
						<!--<table class="layui-table layui-form" id="table">-->
						<!--<span style="float: left">共计***条数据</span>-->
						<!--<div class="layui-btn-container">-->
						<!--<button class="layui-btn layui-btn-sm" style="float: right;">下载模板</button>-->
						<!--<button class="layui-btn layui-btn-sm" style="float: right;">导入</button>-->
						<!--</div>-->
						<!--</table>-->
						<div class="layui-form">
							<table class="layui-table" id="table">
								<span>共计{{total}}条数据</span>
								<a class="layui-btn layui-btn-sm" style="float: right;" href="https://dzxh.oss-cn-hangzhou.aliyuncs.com/excel/%E8%A3%81%E5%88%A4%E6%A8%A1%E6%9D%BF%E8%A1%A8.xls" target="_blank">下载模板</a>
								<button class="layui-btn layui-btn-sm" @click="bullet" style="float: right;margin-right:22px">导入</button>&nbsp;
							</table>
						</div>
						<section id="test1" style="display:none"></section>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>
</body>
<input type="file" id="p1" style="display:none">
<script src="./js/vue.js"></script>
<script>
var form
layui.use(['form', 'table'], function () {
	 form = layui.form
	// layer.msg('玩命卖萌中', function(){
	//   //关闭后的操作
	//   });
	//监听提交
	// form.on('submit(sreach)', function (data) {
	// 	console.log(data)
	// 	app.queryByAccount(data.field.number)
	// 	// layer.msg(JSON.stringify(data.field), function () {
	// 	// location.href = 'index.html'
	// 	// })
	// 	return false
	// })
	// alert(JSON.stringify(app.list))
	var  table = layui.table
	table.render({
		elem: '#table',
		height: 500,
		cols: [app.cols],
		data: app.list,
		page:true,
		limit:50,
		//gender:{"male":"男"},
		status: ['审核', '待审核', '通过', '不通过'],
		participate: ['审核', '参赛', '弃权']
	})
})


var baseurl="https://serviceprod.kpcb.org.cn"
var fileInput1 = document.getElementById("p1");
fileInput1.addEventListener('change', function(event) {
            var filevalue = fileInput1.value;
            var index = filevalue.lastIndexOf('.');
            var kuozhanming=filevalue.substring(index)

 upload_file = fileInput1.files[0];
 if (upload_file==undefined){
   return false
 }
// 或file = fileInput.files.item(0);
var formdata = new FormData();
formdata.append('file', upload_file);
    url =baseurl+ '/abkj-api-match-provider/excel/importJudge'
		  var prjName="mgr_"
			// alert(localStorage.getItem(prjName+"token"))
    $.ajax({
  "method": "post",
url: url,
"headers":{
	"Authorization":localStorage.getItem(prjName+"token")
},
data: formdata,
processData: false,//重要
contentType: false,//重要
success: function (data) {
	//  alert(JSON.stringify(data))
   if (data.message=='success'){
		  alert("裁判导入成功！")
			 location.reload()
			return false
	 }
	 else {
		 alert("裁判导入失败！")
		 location.reload()
		return false
	 }


}})

}, false);
var app = new Vue({
	el: '#content',
	data: {
		gradeList: [],
		matchList: [],
		zoneList: [],
		scheduleList: [],
		userInfoList: [],
		list: [],
		total:0,
		aaa: 123,
		gender: {'male': '男'},
		status: ['审核', '待审核', '通过', '不通过'],
		participate: ['审核', '参赛', '弃权'],
		cols: [ //表头
					{field: 'index', title: '序号', width: 80},
					{field: 'userName', title: '账号'},
					{field: 'name', title: '姓名'},
					// {field: 'project', title: '证件'},
					{field: 'idcard', title: '证件号'},
					{field: 'gender', title: '性别',templet: '#gender'},
					{field: 'job', title: '职务'},
					{field: 'workUnit', title: '所在学校(就读学校)'},

					{field: 'email', title: '电子邮箱'},
					{field: 'isProhibit', title: '审核状态', templet: '#status'},
					{field: 'createTime', title: '注册时间', width: 110},
					{field: 'operating', title: '操作', width: 135, templet: '#operating'},
		]
	},
	mounted: function () {
			this.getData()
			var vm=this;
			layui.use('form',function(){
				layui.form.on('submit(search)', function (data) {
						console.log(data)

						// layer.msg(JSON.stringify(data.field), function () {
						// location.href = 'index.html'
						// })
						return false
					})
			})
		},
	methods: {
		opentab: function (name, url) {
			//单击事件
			console.log(name)
			console.log(url)
			xadmin.add_tab(name, url)
		},
		bullet:function(){
		p1.click()
		},
		queryByAccount:function(varAccount){
			var param = {
				page: {
					current: 1, //当前页数
					size: 10   //每页长度
				},
				cond:{
					eq:{
						roleId:4,
						userName:varAccount
					}
				}
			}

			AdminZoneViewPageList(param,function(data){

				console.log(data)
				app.userInfoList = data.records
				app.list = app.userInfoList
				for ( i = 0; i < data.records.length; i++) {
					app.list[i].index =i;

				}
			  // alert(JSON.stringify(app.list))
			})
		},
		loadConditionData: function () {

			var param = {
				eq:{
					roleId:4
				}
			}
			var funTool = fun_tool();
			app.zoneList=funTool.getAdminZoneIds();
			// alert(JSON.stringify(app.zoneList))
			UserinfoViewqueryList(param,function(data){
				// alert(JSON.stringify(data))
				app.userInfoList = data
				app.list = app.userInfoList
				data.records=data
				for (var i = 0; i < data.records.length; ++i) {
					 app.list[i].index=i+1
					 if (data.records[i].gender=='male'){
						 app.list[i].gender='男'
					 }
					 else {
						 app.list[i].gender	='女'
					 }
				}
				var list=[]
				for (i=0;i<app.list.length;i++){

				}
				app.total=app.list.length
			})
			// ,
			// getJudgment(param, function (data) {
			// 	userInfoList = data.userList
			// 	app.list = data.userList
			// 	for (var i = 0; i < data.length; ++i) {
			// 		app.list[i].index = i
			// 	}
			// }, function (status, message) {

			// })
		},
		getData() {
			this.loadConditionData()

			this.init()
		},
		stop: function (data) {
			data = JSON.parse(data)
			var text = data.isProhibit === 1 ? '启用' : '禁用'
			var reqObj={
				id:data.id,
				isProhibit:data.isProhibit === 1?0:1
			}
			// 禁用启用逻辑
			layer.confirm('确定' + text + '吗？', function () {
				// 掉接口
				AccountupdateById(reqObj,function(data){
					layer.msg(text + '成功!', {icon: 1})
					location.reload()
				})

			})
		},
		init: function () {
			var that = this
			layui.use(['laypage'], function () {
				var laypage = layui.laypage

				//执行一个laypage实例
				laypage.render({
					elem: 'test1' //注意，这里的 test1 是 ID，不用加 # 号
					, count: 16 //数据总数，从服务端得到
				})
			})
		}
	}
})
window.onload = function () {
	app.getData()
}
</script>
<script src="./js/jquery.min.js"></script>
<script type="text/html" id="status">
<a href="javascript:;" class="layui-table-link">
	<div>
	            {{# var fu = function(){
	                            var status = d.status;
	                            if(status == 0){return "未审核";}
	                            else if(status == 1){return "审核通过";}
	                            else if(status == 2){return "审核未通过";}

	                        }
	            }}
	            {{fu()}}
</a>
</script>
<script type="text/html" id="operating">
<a href="javascript:;" class="layui-table-link" onclick=app.stop('{{JSON.stringify(d)}}')>{{ d.isProhibit === 1 ? '启动' : '禁用' }}</a>
<a href="javascript:;" onclick="xadmin.open('审核','review1.html?userId={{d.id}}',600,400)" class="layui-table-link">审核</a>
<a href="javascript:;" onclick="parent.xadmin.open('裁判详情','refereeDetails.html?userId={{d.id}}')" class="layui-table-link">查看</a>
</script>
<!--<script type="text/html" id="status">-->
<!--{{# const a = ['','待审核' ,'通过', '不通过' ] }}-->
<!--{{#  if(d.status  ===  1){ }}-->
<!--<a href="javascript:;" class="layui-table-link">{{app.status[d.status]}}</a>-->
<!--{{#  } else { }}-->
<!--{{a[d.status]}}-->
<!--{{#  } }}-->
<!--</script>-->
<script>
$(function () {

})
function search1(){

		 var n1=document.getElementById("zhuangtai").value
		 // var n2=document.getElementById("saiqu").value
		 var n3=document.getElementById("zhanghao").value
		 var list=[]
		 // alert(JSON.stringify(app.list))
		 for (i=0;i<app.list.length;i++){
        var t1=app.list[i].status
				t1=t1.toString()
				// alert(t1)
				var t2=app.list[i].userName
				// alert(t2)
				if (t1.indexOf(n1)>-1&&t2.indexOf(n3)>-1){
					list.push(app.list[i])
				}

		 }
		 // alert(JSON.stringify(list))
		 var  table = layui.table
 		table.render({
 			elem: '#table',
 			height: 500,
 			cols: [app.cols],
 			data: list,
 			page:true,
 			limit:50,
 			//gender:{"male":"男"},
 			status: ['审核', '待审核', '通过', '不通过'],
 			participate: ['审核', '参赛', '弃权']
 		})

}
</script>

</html>
